   import flash.events.Event;
    import flash.media.Sound;
    import flash.media.SoundChannel;

    class SoundPlayer
    {

        private var sound:Sound;
        private var ch:SoundChannel;
        private var isSoundPlaying:Bool;

        public function new (inSound:Sound)
        {
            sound = inSound;
            isSoundPlaying = false;
        } 

        public function getPosition():Float
        {
          return ch.position;
        }

        public function play(inPosition:Float)
        {
            if(!isSoundPlaying)
            {
                ch = sound.play(inPosition);
                ch.addEventListener(
                    Event.SOUND_COMPLETE,
                    handleSoundComplete);
                isSoundPlaying = true;
            }
        }

        public function stop()
        {
            if(isSoundPlaying)
            {
                ch.stop();
                isSoundPlaying = false;
            }
        }

        private function handleSoundComplete(ev:Event)
        {
            isSoundPlaying = false;
        }
    }
